package com.alpha.feign.common;

import com.alpha.core.http.Response;
import com.alpha.feign.common.entity.Attribute;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 字段属性对外接口
 *
 * @author chenruwan
 * @since 2022-01-01
 */
@FeignClient(value = "alpha-common", contextId = "attribute")
public interface AttributeFeignClient {
    /**
     * 查询字段属性列表
     *
     * @param tableName 表名
     * @return 字段属性列表
     */
    @GetMapping("/attributes")
    @Cacheable(value = "attributes", key = "#tableName")
    Response<Page<Attribute>> query(@RequestParam("tableName") String tableName);

    /**
     * 批量新增或更新字段属性
     *
     * @param attributes 字段属性列表
     * @return Response
     */
    @PutMapping("/attributes")
    Response<Object> saveOrUpdate(@RequestBody List<Attribute> attributes);
}
